package com.lingyuan.product.web;

import com.lingyuan.product.domain.vo.ItemVo;
import com.lingyuan.product.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.concurrent.ExecutionException;

@Controller
public class PmsController {
//    @Autowired
//    private CategoryService categoryService;
    @Autowired
    private SkuService skuService;
//    @GetMapping("/index.html")
//    public String index(Model model)
//    {
//        List<CategoryEntity> categoryEntities = categoryService.selectCategoryTree();
//        model.addAttribute("categoryEntitiesList",categoryEntities);
//        return "index";
//    }


    @GetMapping("/{skuId}.html")
    public String item(@PathVariable("skuId")Long skuId,Model model) throws ExecutionException, InterruptedException {
        ItemVo imteVo = skuService.findInfo(skuId);
        model.addAttribute("itemVo",imteVo);
        return "item";
    }
}
